// 1.导入组件
import { createVNode, render } from 'vue'
import XtxMessage from './xtx-message.vue'

// 2.准备Dom容器
const div = document.createElement('div')
div.setAttribute('class', 'xtx-message-wrapper')
document.body.appendChild(div)
let time = null
export default ({ text, type }) => {
  const vnode = createVNode(XtxMessage, { text, type })
  render(vnode, div)
  // 5. 设置定时器清空
  clearTimeout(time)
  time = setTimeout(() => {
    render(null, div)
  }, 2000)
}
